//
//  NewShangJiaRenZhengViewController.m
//  wangzhe
//
//  Created by 李 佳伟 on 2018/3/15.
//  Copyright © 2018年 李 佳伟. All rights reserved.
//

#import "NewShangJiaRenZhengViewController.h"
#import "JTCSM.h"
#import "MyInfoView.h"
#import "MyDoubleLabelView.h"
#import "NewShangjiaInfoRenzhengViewController.h"
#import "NewShangJiaJiesuanViewController.h"
#import "NewShangjiaImageinfoViewController.h"
#import "NewShouHuoAddressViewController.h"

@interface NewShangJiaRenZhengViewController ()<UINavigationControllerDelegate>
{
    UIImageView *headerImageView;
}
@property (nonatomic,strong) UIImageView *logoImageV;
@property (nonatomic,strong) MyDoubleLabelView *bottomDoubleView;
@end

@implementation NewShangJiaRenZhengViewController
- (void)gotBack{
    [self.navigationController popViewControllerAnimated:YES];
}
// 将要显示控制器
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
    // 判断要显示的控制器是否是自己
    BOOL isShowHomePage = [viewController isKindOfClass:[self class]];
    [self.navigationController setNavigationBarHidden:isShowHomePage animated:YES];
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:YES];
    self.navigationController.delegate = self;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [df isRemoveTarbar:YES];
    self.view.backgroundColor = RGBACOLOR(242, 242, 242, 1);
    headerImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, KCONTROLLERWith, KCONTROLLERWith*0.6667)];
    headerImageView.image = [UIImage imageNamed:@"商家认证_背景.png"];
    [self.view addSubview:headerImageView];
    UIImage * firstImage = [UIImage imageNamed:@"fanhui.png"];
    CGRect firstFrame = CGRectMake(20, 20, 50, 44);
    CGFloat width = firstFrame.size.width;
    CGFloat height = firstFrame.size.height;
    CGFloat imagesize = 20;
    UIButton * leftButton = [[UIButton alloc]initWithFrame:firstFrame];
    [leftButton setImage:firstImage forState:UIControlStateNormal];
    [leftButton addTarget:self action:@selector(gotBack) forControlEvents:UIControlEventTouchUpInside];
    leftButton.imageEdgeInsets = UIEdgeInsetsMake((height-imagesize)/2, 0, (height-imagesize)/2, (width-imagesize));
    [self.view addSubview:leftButton];
    UILabel *titleLabel = [UILabel initWithFrame:CGRectMake(0, 20, KCONTROLLERWith, 44) text:@"商家认证" font:20 textAlignment:NSTextAlignmentCenter texcolor:RGBACOLOR(51, 51, 51, 1) backgroundColor:nil];
    [self.view addSubview:titleLabel];
    
    CGFloat logoBackImageWidth = KCONTROLLERWith-40;
    CGFloat logoBackImageHeight = logoBackImageWidth*0.4484;
    CGFloat space = 20;
    UIImageView *logoBackImageV = [[UIImageView alloc]initWithFrame:CGRectMake(space, 128, logoBackImageWidth, logoBackImageHeight)];
    logoBackImageV.image = [UIImage imageNamed:@"商家认证_头像背景.png"];
    [self.view addSubview:logoBackImageV];
    
    CGFloat logoImageVSize = 60;
    self.logoImageV = [[UIImageView alloc]initWithFrame:CGRectMake((KCONTROLLERWith-logoImageVSize)/2, 98, logoImageVSize, logoImageVSize)];
    self.logoImageV.image = [UIImage imageNamed:@"个人信息_头像.png"];
    [self.view addSubview:self.logoImageV];
    
    CGFloat doubleViewHeight = logoBackImageHeight-30-logoBackImageHeight*0.2724;
    self.bottomDoubleView = [[MyDoubleLabelView alloc]initWithFrame:CGRectMake(0, 30, logoBackImageV.LC_width, doubleViewHeight) titleFontsize:15 titlecolor:[df colorWithHexString:@"333333" alpha:1] contentFontsize:15 contentcolor:[df colorWithHexString:@"333333" alpha:1]];
    [logoBackImageV addSubview:self.bottomDoubleView];
    [self.bottomDoubleView InsertSpacesetvalueWithModel:@{KDoubleLabelTitle:@"认证通过获得",KDoubleLabelContent:@"价值18.88台牌一套"} changeLabelY:12];
    
    CGFloat infoImageHeight = logoBackImageWidth*0.5407855;
    UIImageView *infoImageV = [[UIImageView alloc]initWithFrame:CGRectMake(space+2, KVIEW_Y(logoBackImageV)+24, logoBackImageWidth-2, infoImageHeight)];
    infoImageV.image = [UIImage imageNamed:@"个人信息_信息背景.png"];
    [self.view addSubview:infoImageV];
    infoImageV.userInteractionEnabled = YES;
    CGFloat top = infoImageHeight *0.02793;
    CGFloat infospace = infoImageV.LC_width*22/993;
    CGFloat labelHeight = infoImageHeight*165/537;
    CGFloat labelWidth = infoImageV.LC_width-2*infospace;
    
    NSArray *array = @[@"基本信息",@"结算信息",@"证件照片"];
    NSArray *imageArray = @[@"个人信息_基本信息.png",@"个人信息_结算信息.png",@"个人信息_证件照片.png"];
    for (int i = 0; i < array.count; i++) {
        MyInfoView *view1 = [[MyInfoView alloc]initWithFrame:CGRectMake(infospace, top+labelHeight*i, labelWidth, labelHeight) imagename:imageArray[i] title:array[i] placeholder:nil isShowLabel:ImageViewType radioBtnIndex:0 GroupId:@""];
        view1.tag = 100+i;
        view1.backgroundColor = [UIColor clearColor];
        view1.userInteractionEnabled = YES;
        [df addTapGestureRecognizerWithTarget:self action:@selector(gotoVC:) andaddView:view1];
        [infoImageV addSubview:view1];
        
    }
    
    MyInfoView *view1 = [[MyInfoView alloc]initWithFrame:CGRectMake(infoImageV.LC_x+infospace, KVIEW_Y(infoImageV)+24, infoImageV.LC_width-2*infospace, labelHeight) imagename:@"个人信息_收货地址.png" title:@"收货地址" placeholder:nil isShowLabel:ImageViewType radioBtnIndex:0 GroupId:@""];
    view1.tag = 200;
    view1.userInteractionEnabled = YES;
    [df addTapGestureRecognizerWithTarget:self action:@selector(gotoVC:) andaddView:view1];
    [self.view addSubview:view1];
    [df layerWithView:view1 radius:3 width:0 color:nil];
    [df setTheViewYiYing:view1 shadowColor:RGBACOLOR(222, 222,222, 1) shadowOffset:CGSizeMake(3, 3) apla:1];
    
    UILabel *alertLabel = [UILabel initWithFrame:CGRectMake(0, KCONTROLLERHeight-56, KCONTROLLERWith, 29) text:@"蜂窝保障您的信息安全" font:13 textAlignment:NSTextAlignmentCenter texcolor:[df colorWithHexString:@"666666" alpha:1] backgroundColor:nil];
    [self.view addSubview:alertLabel];
}
- (void)gotoVC:(UITapGestureRecognizer *)tap{
    switch (tap.view.tag) {
        case 100:
            [self gotoShangJiaRenzhengVC];
            break;
        case 101:
            [self gotoShangJiaJieSuanVC];
            break;
        case 102:
            [self gotoNewShangjiaImageinfoViewController];
            break;
        case 200:
            [self gotoNewShouHuoAddressViewController];
            break;
            
        default:
            break;
    }
}
- (void)gotoShangJiaRenzhengVC{
    NewShangjiaInfoRenzhengViewController *vc = [[NewShangjiaInfoRenzhengViewController alloc]init];
    vc.nameTitle = @"基本信息";
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)gotoShangJiaJieSuanVC{
    NewShangJiaJiesuanViewController *vc = [[NewShangJiaJiesuanViewController alloc]init];
    vc.nameTitle = @"结算信息";
    [self.navigationController pushViewController:vc animated:YES];
}
- (void)gotoNewShangjiaImageinfoViewController{
    NewShangjiaImageinfoViewController *vc = [[NewShangjiaImageinfoViewController alloc]init];
    vc.nameTitle = @"证件照片";
    [self.navigationController pushViewController:vc animated:YES];
}
- (void)gotoNewShouHuoAddressViewController{
    NewShouHuoAddressViewController *vc = [[NewShouHuoAddressViewController alloc]init];
    vc.nameTitle = @"收货地址";
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
